import pandas as pd
#  code字符串类型
df = pd.read_excel('stock.xlsx', dtype={'code':'str'})
year = df.timeToMarket.astype('str').str[:4]  # 转换为字符串，提取前4位的年份
yearnum = df.groupby(year).name.count()
# 按年份统计，得到每年股票发行量
print(yearnum)    # Out: (3678, 22)

